package cn.explink.dop.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.explink.dop.dto.SettleAccoutsRecordDTO;
import cn.explink.dop.service.DeliveryManService;
import cn.explink.dop.service.OrderService;
import cn.explink.dop.service.SettleAccoutsRecordService;
import cn.explink.dop.tools.Tools;

/**
 *
 * @ClassName: SettleAccoutsRecordController
 * @Description: 派费结算历史记录
 * @author 孟凡岭
 * @date 2015年5月6日 下午5:37:07
 * @since AR1.0
 */
@Controller
@RequestMapping("/settleAccoutsRecordController")
public class SettleAccoutsRecordController {

	@Autowired
	private SettleAccoutsRecordService settleAccoutsRecordService;

	@Autowired
	private DeliveryManService deliveryManService;

	@Autowired
	private OrderService orderService;

	/**
	 *
	 * @Title: index1
	 * @Description: 页面跳转
	 * @author 孟凡岭
	 * @param @param request
	 * @param @return
	 * @return ModelAndView 返回类型
	 * @throws
	 */
	@RequestMapping(params = "index1")
	public ModelAndView index1(HttpServletRequest request) {
		ModelAndView view = new ModelAndView("dop/settleAccoutsRecord/settleAccoutsRecord");
		List<Map<String, Object>> deliveryManList = this.deliveryManService.getOpenDeliveryMan();
		String date = Tools.getDateFromToday(0);
		view.addObject("date", date);
		view.addObject("manList", deliveryManList);
		return view;
	}

	/**
	 *
	 * @Title: queryRecord
	 * @Description: 分页加载数据
	 * @author 孟凡岭
	 * @param @param record
	 * @param @param pageNum
	 * @param @param pageSize
	 * @param @param request
	 * @param @return
	 * @return Map<String,Object> 返回类型
	 * @throws
	 */
	@RequestMapping(params = "queryRecord")
	@ResponseBody
	public Map<String, Object> queryRecord(SettleAccoutsRecordDTO record, int pageNum, int pageSize, HttpServletRequest request) {
		Map<String, Object> result = this.settleAccoutsRecordService.queryRecordByPage(record, pageNum, pageSize);
		return result;
	}

	/**
	 *
	 * @Title: getRecordDetail
	 * @Description: 通过派费历史记录查看详情
	 * @author 孟凡岭
	 * @param @param deliveryManId
	 * @param @param returnDate
	 * @param @param request
	 * @param @return
	 * @param @throws Exception
	 * @return List<OrderVO> 返回类型
	 * @throws
	 */
	@RequestMapping(params = "getRecordDetail")
	@ResponseBody
	public Map<String, Object> getRecordDetail(int pageNum, int pageSize, String deliveryManId, String returnDate, String returnRecordId, HttpServletRequest request) throws Exception {
		return this.orderService.getRecordDetail(pageNum, pageSize, deliveryManId, returnDate, returnRecordId);
	}
}
